package com.zhenghaijin.commentservice.mapper;

import com.zhenghaijin.commentservice.model.Comment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    @Select("SELECT * FROM comments WHERE anime_id = #{animeId}")
    List<Comment> findByAnimeId(Long animeId);

    @Insert("INSERT INTO comments(user_id, anime_id, content, created_at, updated_at, status) " +
            "VALUES(#{userId}, #{animeId}, #{content}, #{createdAt}, #{updatedAt}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Comment comment);

    @Delete("DELETE FROM comments WHERE id=#{id}")
    int deleteById(Long id);
}
